﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace msBsc.WebUi
{
    public partial class mfShowVehicleDetail : msBsc.Cls.mbPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        public override void DoAction()
        {
            if (this.strAction == "GetVehicleDetail")
            {
                GetVehicleDetail();
            }
            if (this.strAction == "ShowConaction")
            {
                ShowDjackConaction();
            }
        }

        private void GetVehicleDetail()
        {
            string vehicleId = this.GetParamHtValue("VehicleId");

            if (string.IsNullOrEmpty(vehicleId))
            {
                this.ExecJScript("alert('车辆信息有误')");
                return;
            }

            DataSet ds = new msBsc.AppLogic.DataAlc.CBizVehicleInfo().SelectByIds(string.Empty, vehicleId);

            if (ds == null || ds.Tables[0].Rows.Count <= 0)
            {
                this.ExecJScript("alert('该车辆信息不存在')");
                return;
            }

            string djackHead = "" + ds.Tables[0].Rows[0]["CUSTOMER_DEFAULT_PIC"].ToString();

            string brandAndSeat = Enum.GetName(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.VehicleBrandEnum), ds.Tables[0].Rows[0]["VEHICLE_BRAND"]) + " | " + ds.Tables[0].Rows[0]["VEHICLE_SEATS"].ToString() + "座";

            string serviceType = "服务类型：" + Enum.GetName(typeof(msBsc.AppLogic.DataAlc.cls.CommonEnum.ServiceTypeEnum), ds.Tables[0].Rows[0]["VEHICLE_SERVICE_TYPE"]);

            string serviceArea = "服务范围：" + ds.Tables[0].Rows[0]["VEHICLE_SERVICE_AREA"].ToString();

            string vehicleCode = "车辆编号：" + ds.Tables[0].Rows[0]["VEHICLE_CODE"].ToString();

            this.ExecJScript("$('#imgVehicleDefault').attr('src','" + ds.Tables[0].Rows[0]["VEHICLE_DEFAULT_PIC"].ToString() + "');$('#imgDjackPic').attr('src','" + djackHead + "');$('#vehicleName').text('" + ds.Tables[0].Rows[0]["VEHICLE_NAME"].ToString() + "');$('#mbPrice label').text('" + ds.Tables[0].Rows[0]["VEHICLE_PRICE_DAY"].ToString() + "');$('#mbBrandSeats').text('" + brandAndSeat + "');$('#serviceType').text('" + serviceType + "');$('#serviceArea').text('" + serviceArea + "');$('#vehicleNum').text('" + vehicleCode + "');$('.ShowBuyShouldKnow').text('" + ds.Tables[0].Rows[0]["ORDER_SHOULD_KNOW"].ToString() + "');$('#hidDjackId').val('" + ds.Tables[0].Rows[0]["DJACK_ID"].ToString() + "')");

        }

        private void ShowDjackConaction()
        {
            string djackId = this.GetParamHtValue("DjackId");

            if (string.IsNullOrEmpty(djackId))
            {
                this.ExecJScript("alert('地接客信息有误')");
                return;
            }

            DataSet ds = new msBsc.AppLogic.DataAlc.CBizVehicleInfo().SelectByIds(djackId, string.Empty);

            if (ds == null || ds.Tables[0].Rows.Count <= 0)
            {
                this.ExecJScript("alert('该地接客暂无联系方式')");
                return;
            }

            this.ExecJScript("$('#labPhone').text('" + ds.Tables[0].Rows[0]["CUSTOMER_BASEINFO_MOBILE"].ToString() + "');$('#labEmail').text('" + ds.Tables[0].Rows[0]["CUSTOMER_BASEINFO_EMAIL"].ToString() + "');$('#labQQ').text('" + ds.Tables[0].Rows[0]["CUSTOMER_BASEINFO_QQ"].ToString() + "');$('#labWechat').text('" + ds.Tables[0].Rows[0]["CUSTOMER_WECHAT_NO"].ToString() + "');");
        }
    }
}